<?php
namespace App\Listener\User;

use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Event\Annotation\Listener;

use App\Query\ConfigQuery;

/**
 * @Listener 
 */
class RegisterMoneyListener implements ListenerInterface
{
    public function listen(): array
    {
        return [
            \App\Event\User\CreateEvent::class,
        ];
    }
    
    // 注册送积分
    public function process($event)
    {
        $user = $event->user;
        
        // 配置
        $config = ConfigQuery::get();
        
        $content = '新用户注册赠送';
        
        $user->addMoney('money', $config['user_reg_money'], $content);
        $user->addMoney('money_make', $config['user_reg_money_make'], $content);
        $user->addMoney('money_shop', $config['user_reg_money_shop'], $content);
        $user->addMoney('money_point', $config['user_reg_money_point'], $content);
        $user->addMoney('money_other', $config['user_reg_money_other'], $content);
    }
}